import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Login from '../views/Login.vue'
import Index from '../views/Index.vue'
import Essay from '../views/board/Essay.vue'
import Admin from '../views/board/Admin.vue'

Vue.use(VueRouter)
const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/',
    name: 'Index',
    component: Index,
    redirect: 'essay',
    children: [
      {
        path: 'essay',
        name: 'Essay',
        component: Essay
      },          
      {
        path: 'admin',
        name: 'Admin',
        component: Admin
      },
    ]
  },
  {
    path: '/hoe',
    name: 'Home',
    component: Home
  },

]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
